CakeTicker.RegisterNamespace('CakeTicker.Users');

CakeTicker.Users.Register = new function()
{
	var validator = null;
	var config = {
			username: "#UserUsername",
			email: "#UserEmail",
			confirmEmail:"#UserConfirmEmail",
			password:"#UserPassword",
			confirmPassword:"#UserConfirmPassword"
	}
	
	function initialise()
	{
		validator = $("#UserRegisterForm").validate();
		
		$(config.username).rules("add", {required: true, messages: {required: "Enter a username"}});
		$(config.email).rules("add", {required: true, email: true, messages: {required: "Please enter a valid email address"}});
		$(config.confirmEmail).rules("add", {required: true, email: true, equalTo:config.email, messages: {equalTo: "Enter the same email as above"}});
		$(config.password).rules("add", {required: true, minlength: 5, messages: {required: "Enter a password", minlength: jQuery.format("Enter at least {0} characters")}});
		$(config.confirmPassword).rules("add", {required: true, minlength: 5, equalTo:config.password, messages: {required: "Repeat yuor password", minlength: jQuery.format("Enter at least {0} characters"), equalTo: "Enter the same password as above"}});
	}
	
	return {initialise:initialise}
}();

$(document).ready(CakeTicker.Users.Register.initialise);